print('Введите скобочную последовательность:')
s =  input()
s1 = ""
for a in s:
    if a == "(":
        s1 += a
    if a == ")":
        if len(s1)>0:
            if s1[len(s1)-1] == "(":
                s1 = s1[:-1]
    if a == "[":
            s1 += a
    if a == "]":
        if len(s1)>0:
            if s1[len(s1)-1] == "[":
                s1 = s1[:-1]
    if a == "<":
        s1 += a
    if a == ">":
        if len(s1)>0:
            if s1[len(s1)-1] == "<":
                s1 = s1[:-1]
    if a == "{":
        s1 += a
    if a == "}":
        if len(s1)>0:
            if s1[len(s1)-1] == "{":
                s1 = s1[:-1]
    print(s1)
if len(s1)==0:
    print("True")
else:
    print("False")
